﻿@using Telerik.Web.Mvc.UI
@model EcBlog.Models.Page


@{  
    ViewBag.Title = Model.Title;
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

@section head {
    @Html.Partial("_Head")
    <style> 
        #ContentHtml
        {
            height: 650px;
            width: 980px;
        }
    </style>
}

 @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)

@Html.EditorForModel()

     <p><input type="submit" value="Save" /> 
     <span id="undo" class="t-button">View Html</span>

         @if(Model.PageId > 0)
        {
            @Html.ActionLink("Preview", "Preview", "Page", new { area = "Admin", pageId = Model.PageId },new{target="_blank"})
        }
     </p>   
       
     <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
 }
 
 
 @{ Html.Telerik().Window()
        .Name("Window")
        .Title("Post HMTL")
        .Draggable(true)
        .Resizable(resizing => resizing
            .Enabled(true)
            .MinHeight(450)
            .MinWidth(450)
            .MaxHeight(900)
            .MaxWidth(900)
        )
        .Modal(true)
        .Buttons(b => b.Maximize().Close())
        .Content(@<text>
<textarea id="generated-markup" rows="10" cols="80" title="generated-markup" class="editor-field"  style="width: 90%; height: 90%;"></textarea>
                         <button onclick="$('#generated-markup').val($('#ContentHtml').data('tEditor').value());">Get HTML</button>
                         <button onclick="$('#ContentHtml').data('tEditor').value($('#generated-markup').val());" style="float: right;">Set HTML</button><br />
        </text>)
        .Visible(false)
        .Render();
}

@{ Html.Telerik().ScriptRegistrar()
        .OnDocumentReady(@<text>
            var windowElement = $('#Window');
            var undoButton = $('#undo');
            undoButton
                .bind('click', function(e) {
                    windowElement.data('tWindow').center();
                    windowElement.data('tWindow').open();
                    undoButton.hide();
                })
                .toggle(!windowElement.is(':visible'));
                
            windowElement.bind('close', function() {
                undoButton.show();
            });
        </text>);
}
           

